package com.xmmj.baselibrary.utils.adapter.viewpager

import androidx.fragment.app.*
import androidx.viewpager2.adapter.FragmentStateAdapter

class ViewPagerAdapter(fm: FragmentManager, private val mFragments: List<Fragment>) :
    FragmentStatePagerAdapter(fm) {

    override fun getCount(): Int {
        return mFragments.size
    }

    override fun getItem(position: Int): Fragment {
        if (mFragments.isEmpty()) {
            return null!!
        }
        return if (position < mFragments.size) mFragments[position] else null!!
    }
}